﻿@model Gueei.Gallery.Web.ViewModels.BatchUploadViewModel
@{
    Layout = null;
}

<div class="edit-images">
    @for(int i=0; i<Model.Images.Count(); i++)
    {
        <fieldset>
            <div class='preview'>
                <img src="./PreviewImage?imageId=@Model.Images[i].Id" alt="preview"/>
            </div>
            @Html.HiddenFor(m => Model.Images[i].Id)
            <p>
                @Html.LabelFor(m => Model.Images[i].Name) @Html.TextBoxFor(m => Model.Images[i].Name, new { @class = "auto-imagename" })
            </p>
            <p>
                @Html.LabelFor(m => Model.Images[i].Tags) @Html.TextBoxFor(m => Model.Images[i].Tags, new { @class = "autocomplete tags auto-imagetags", @ref = "/Search/Tags" })
            </p>
            <p>
                @Html.LabelFor(m => Model.Images[i].Description) @Html.TextAreaFor(m => Model.Images[i].Description)
            </p>
        </fieldset>
    }
</div>
<script type="text/javascript">
    $(function () {
        $("#SetNameDefaultButton").click(function () {
            var defaultname = $("#defaultName").val();
            $(".auto-imagename").each(function (i) {
                $(this).val(defaultname + "(" + (i + 1) + ")");
            });
        });
        $("#SetTagsDefaultButton").click(function () {
            var defaulttags = $("#defaultTags").val();
            $(".auto-imagetags").each(function (i) {
                $(this).val(defaulttags);
            });
        });
    });
</script>